package tdca.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import tdca.activity.R;
import tdca.util.DataUtil;

public class PrivateQA extends Activity {
    TextView privateqa_question_textview,privateqa_answer_textview;
    Button privateqa_btn_right,privateqa_btn_wrong,private_btn_return;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.privateqa);

        privateqa_question_textview = (TextView) findViewById(R.id.privateqa_question);
        privateqa_answer_textview = (TextView) findViewById(R.id.privateqa_answer);

        privateqa_btn_right = (Button) findViewById(R.id.privateqa_btn_pass);
        privateqa_btn_wrong = (Button) findViewById(R.id.privateqa_btn_fail);
        private_btn_return = (Button) findViewById(R.id.private_btn_return);
    }

    @Override
    protected void onResume() {
        super.onResume();    //To change body of overridden methods use File | Settings | File Templates.

        if(DataUtil.instance().getPrivateCode() != null){

            privateqa_question_textview.setText("\n\t"+DataUtil.instance().getPrivateInfo()[0]+"\n\n\n");
            privateqa_answer_textview.setText("\n\t"+DataUtil.instance().getPrivateInfo()[1]+"\n\n\n");

            privateqa_btn_right.setOnClickListener(new Listener_btn_passed());
            privateqa_btn_wrong.setOnClickListener(new Listener_btn_failed());
            private_btn_return.setOnClickListener(new Listener_btn_return());
        }else{
            Toast.makeText(PrivateQA.this,"请先扫描私章，再进入私密信息验证模块",Toast.LENGTH_LONG).show();
            PrivateQA.this.finish();
        }
    }

    class Listener_btn_passed implements Button.OnClickListener{
        public void onClick(View view) {
            //To change body of implemented methods use File | Settings | File Templates.
//        	DataUtil.instance().setFlag_3_privateQ_Match_privateA(true);
            Toast.makeText(PrivateQA.this,"私密信息验证通过！",Toast.LENGTH_SHORT).show();
            PrivateQA.this.finish();
        }
    }

    class Listener_btn_failed implements Button.OnClickListener{
        public void onClick(View view) {
            //To change body of implemented methods use File | Settings | File Templates.
//            DataUtil.instance().setFlag_3_privateQ_Match_privateA(false);
            Toast.makeText(PrivateQA.this,"私密信息验证失败！",Toast.LENGTH_SHORT).show();
            PrivateQA.this.finish();
        }
    }

    class Listener_btn_return implements View.OnClickListener{
        public void onClick(View view) {
            //To change body of implemented methods use File | Settings | File Templates.
            finish();
        }
    }
}